//
//  TPUserInfoCell.m
//  Tripvi
//
//  Created by xiaowuxiaowu on 2017/6/15.
//  Copyright © 2017年 xiaowuxiaowu. All rights reserved.
//

#import "TPUserInfoCell.h"
@interface TPUserInfoCell()

@end
@implementation TPUserInfoCell
@synthesize indexPath = _indexPath;

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.textLabel.textColor = TPAllBackgroundColor;
        self.detailTextLabel.textColor = TPBlack_333333;
        [self.image_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-2.0f);
            make.centerY.mas_equalTo(self);
            make.size.mas_equalTo(CGSizeMake(40.0, 40.0));
        }];
        
        _textField = [UITextField initWithFrame:CGRectZero borderStyle:UITextBorderStyleNone fontSize:16 placeholder:@"" text:@""];
        [self.contentView addSubview:_textField];
        _textField.textAlignment = NSTextAlignmentRight;
        [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-10.0);
            make.top.bottom.mas_equalTo(0.0);
            make.width.mas_equalTo(150.0);
        }];
       
    }
    
    return self;
}

-(void)setIndexPath:(NSIndexPath *)indexPath{
    _indexPath = indexPath;
   
    _textField.tag = indexPath.row;
    _textField.enabled = indexPath.row==1 ||indexPath.row==2;
    self.image_view.hidden = YES;
     self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    switch (indexPath.section) {
        case 0:{
            switch (indexPath.row) {
                case 0:
                {
                    self.image_view.hidden = NO;
                    self.detailTextLabel.text = @"";
                }
                    break;
                case 4:{
                    
                }
                    break;
                    
                default:
                    break;
            }
        }
            break;
            
        default:
            break;
    }
}
-(void)buttonClick:(UIButton *)sender{

    if([self.delegate respondsToSelector:@selector(tpUserInfoCellWithButton:withSwit:indexPath:)]){
        [self.delegate tpUserInfoCellWithButton:sender withSwit:nil indexPath:_indexPath];
    }
    
}
-(void)switClick:(UISwitch *)swith{
    if([self.delegate respondsToSelector:@selector(tpUserInfoCellWithButton:withSwit:indexPath:)]){
        [self.delegate tpUserInfoCellWithButton:nil withSwit:swith indexPath:_indexPath];
    }
}
-(void)layoutSubviews{
    [super layoutSubviews];
    
    
    ViewRadius(self.image_view, 20.0f);
    
}

@end
